#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "anytimer.h"

//函数1
static void f1(void * p)
{
    printf("f1():%s", (char *)p);
}
//函数2
static void f2(void * p)
{
    printf("f2():%s", (char *)p);
}

int main()
{
    int job1, job2, job3, ret;
    puts("begin\n");
    //添加任务
    job1 = at_addjob(5, f1, "aaa");
    if(job1 < 0)
    {
        fprintf(stderr, "job1 at_stdjob:%s\n", strerror(-job1));
        exit(1);
    }
    job2 = at_addjob(2, f2, "bbb");
    if(job2 < 0)
    {
        fprintf(stderr, "job2 at_stdjob:%s\n", strerror(-job2));
        exit(1);
    }
    job3 = at_addjob(7, f1, "ccc");
    if(job3 < 0)
    {
        fprintf(stderr, "job3 at_stdjob:%s\n", strerror(-job3));
        exit(1);
    }
    //取消任务
    ret = at_canceljob(job1);
    if(ret < 0)
    {
        fprintf(stderr, "cancel:%s\n", strerror(-ret));
        exit(1);
    }

    puts("end\n");

    while(1)
    {
        write(1, ".", 1);
        sleep(1);
    }
}